//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.highglass.videoplayer.subTitle.autodetect;

public class nsDetector extends nsPSMDetector implements nsICharsetDetector {
    nsICharsetDetectionObserver mObserver = null;

    public nsDetector() {
    }

    public nsDetector(int langFlag) {
        super(langFlag);
    }

    public void Init(nsICharsetDetectionObserver aObserver) {
        this.mObserver = aObserver;
    }

    public boolean DoIt(byte[] aBuf, int aLen, boolean oDontFeedMe) {
        if(aBuf != null && !oDontFeedMe) {
            this.HandleData(aBuf, aLen);
            return this.mDone;
        } else {
            return false;
        }
    }

    public void Done() {
        this.DataEnd();
    }

    public void Report(String charset) {
        if(this.mObserver != null) {
            this.mObserver.Notify(charset);
        }

    }

    public boolean isAscii(byte[] aBuf, int aLen) {
        for(int i = 0; i < aLen; ++i) {
            if((128 & aBuf[i]) != 0) {
                return false;
            }
        }

        return true;
    }
}
